<?php

// EUROPA 100 AD
//
// Main Handler
//
// August 2007 (K. Dougans)

# Compress the output
ob_start("ob_gzhandler");

# Get the configurations
require_once('/Users/kevindougans/Sites/europa100ad.com/includes/config.inc.php');

log_memory("--\n --\n".$_SERVER['REQUEST_URI']." requested at ".NOW);

# Set variables (if any)
$user_check = new user();

# Check the session ID (from url) is valid
$uid = $user_check->uid_check($_REQUEST['uid']);
define("UID",$uid);

/*
Compression idea for review later - KD Sep 07
*/
//write('test');
# display main content
//print($buffer);


# Include the first section of HTML
include_once($config['dir_inc'] . 'header.inc.php');

# Include the section of the game being played - stored in the url as http://ceaser.europa100ad.com/_LANG_/_UID_/_STEP_/
$step = $_REQUEST['step'];

$sql = "SELECT * FROM `core_locations` WHERE `alias`='$step'";
$res = $db->query($sql);

// DEBUG
//printf("Select returned %d rows.\n", $res->num_rows);

$row = $res->fetch_assoc();
$checked_step = $row['location'];
if (strlen($checked_step) > 0)
{
    # Check to see if the page has a default title set (if applic.)
    if (strlen($row['title']) > 0){ $pre = '<h1>'. $row['title'] . '</h1>'; } else { $pre = ''; }
    
    # Include the "section/step"
    echo $pre . '<p>';
    require($config['dir_inc'] . $checked_step);
    echo '</p>';
}
else
{
    // Display an error, and log the error using our game_error function
    game_error('NF');
}  

# Display debug information (TODO - protect this section to admin only)
echo "<p><br><H1>Debug</h1><P>";
echo "<small><b>Query Log</b> ($query_count): $query_log<BR></small><BR>";
echo '</p>';
echo '<pre>';
$defined_vars = get_defined_vars();
echo print_r($defined_vars);
echo '</pre>';
include_once($config['dir_inc'] . 'footer.inc.php');



# Dump the output to browser
ob_end_flush();
?>
